<style>
    .layui-form .layui-form-item .layui-inline .layui-form-label {
        width: 100px;
    }
</style>
<form class="layui-form seller-form" action="">
    <div class="layui-tab">
        <ul class="layui-tab-title">
            <li class="layui-this"><a href="{:url('alipay')}">详细记录</a></li>
            <li><a href="{:url('alipayData')}">统计数据</a></li>
        </ul>
        <div class="layui-tab-content">
            <div class="layui-tab-item layui-show">
                <div class="layui-inline">
                    <div class="layui-input-inline seller-inline-3">
                        <input type="text" name="username" placeholder="用户名称" autocomplete="off"
                               maxlength="50" class="layui-input">
                    </div>
                </div>
                <div class="layui-inline">
                    <div class="layui-input-inline seller-inline-3">
                        <input type="text" name="out_trade_no" placeholder="订单号" autocomplete="off"
                               class="layui-input">
                    </div>
                </div>
                <div class="layui-inline">
                    <div class="layui-input-inline seller-inline-3">
                        <input type="text" name="pay_user" placeholder="支付账号" autocomplete="off"
                               class="layui-input">
                    </div>
                </div>
                <div class="layui-inline">
                    <div class="layui-input-inline seller-inline-3">
                        <input type="text" name="name" placeholder="实名" autocomplete="off"
                               class="layui-input">
                    </div>
                </div>
                <div class="layui-inline">
                    <select name="pay_status" >
                        <option value="">请选择支付状态</option>
                        <option value="0">等待中</option>
                        <option value="1">支付成功</option>
                        <option value="2">支付失败</option>
                    </select>
                </div>
                <div class="layui-inline" style="padding-left: 5px;">
                    <input type="text" name="datetime" id="datetime" placeholder="Start Time _ End Time" autocomplete="off" class="layui-input">
                </div>
                <div class="layui-inline">
                    <div class="layui-input-block">
                        <button class="layui-btn layui-btn-sm" lay-submit lay-filter="search"><i class="iconfont icon-chaxun"></i>Search</button>
                    </div>
                </div>
            </div>
            <div class="layui-tab-item">
                <div class="table-body">
                    <table id="userTable2" lay-filter="test"></table>
                </div>
            </div>

        </div>
    </div>
</form>

<div class="table-body">
    <table id="dataTable" lay-filter="dataTable" ></table>
</div>

<script>
    layui.use(['form',  'laydate' , 'table'], function () {
        var laydate = layui.laydate,
            form = layui.form,
            table = layui.table; //表格
        //时间插件
        laydate.render({
            elem: '#datetime',
            range: '_',
            format: 'yyyy-MM-dd'
        });
        var tableIn = layui.table.render({
            elem: '#dataTable',
            height: 'full-99',
            cellMinWidth: '80',
            totalRow: true,
            url: "{:url('alipay')}",
            method:'POST',
            cols: [[
                { type: 'numbers'},
                { field: 'username', align: 'left',  title: '用户', width: 170},
                { field: 'name', align: 'left',  title: '实名', width: 80},
                { field: 'pay_user', align: 'left',  title: '支付账号'},
                { field: 'out_trade_no', align: 'left',  title: '订单号',width: 240,
                    templet: function (d) {
                        return '<a class="layui-btn layui-btn-xs SearchDetail" data-id="' + d.id + '">详</a> ' + d.out_trade_no;
                    }
                },
                { field: 'amount',  align: 'right', title: '金额($)',width: 90,
                    style:'color:#FF5722;font-weight:bold',totalRow: true},
                { field: 'amount_en',  align: 'right', title: '金额(¥)',width: 90,
                    style:'color:#FF5722;font-weight:bold',totalRow: true},
                { align: 'left', title: '扫码类型',width:90,
                    templet: function (d) {
                        const type=d.type;
                        return (type==1)?'微信':'支付宝';
                    }
                },
                { align: 'left', title: '生成二维码',width:100,
                    templet: function (d) {
                        const status_api=d.status_api;
                        return (status_api==1)?'<span style="color:green">成功</span>':'<span style="color:red">失败</span>';
                    }
                },
                { align: 'left', title: '支付状态',width:90,
                    templet: function (d) {
                        const status_check=d.status_check;
                        var   color = "#6c757d";
                        var   show_name = '等待中';
                        if(status_check == 1){
                            color = 'green';
                            show_name = '已支付';
                        }else if(status_check == 2){
                            color = 'red';
                            show_name = '支付失败';
                        }
                        return '<span style="color: ' + color + '">' + show_name + '</span>';
                    }
                },
                { align: 'left', title: '数据录入',width:90,
                    templet: function (d) {
                        const status_used=d.status_used;
                        return (status_used==1)?'<span style="color:green">已录入</span>':'<span style="color:red">未录入</span>';
                    }
                },
                { field: 'ctime',align: 'center', title: '创建时间',width:180,
                    templet: function (d) {
                        return layui.util.toDateString(d.ctime * 1000, "yyyy-MM-dd HH:mm:ss");
                    }
                },
                { field: 'ctime',align: 'center', title: '结算时间',width:180,
                    templet: function (d) {
                        const utime = d.utime;
                        if (utime == null) {
                            return ' -- ';
                        } else {
                            return layui.util.toDateString(utime * 1000, "yyyy-MM-dd HH:mm:ss");
                        }
                    }
                }
            ]],
            page: true,
            limit: 20,
            limits: [20, 50, 100],
        });
        layui.form.on('submit(search)', function (data) {
            layui.table.reload('dataTable', {
                where: data.field
                , page: {
                    curr: 1 //重新从第 1 页开始
                },
                method:'POST'
            });
            return false; //阻止表单跳转。如果需要表单跳转，去掉这段即可。
        });
        //余额编辑
        $(document).on('click', '.SearchDetail', function () {
            var id = $(this).attr('data-id');
            JsGet("{:url('server/showDetail')}?id="+ id, function(e){
                if(e.status == 1){
                    layer.open({
                        type: 1,
                        title: 'Log Detail',
                        area: ['1000px', '600px'], //宽高
                        content: e.datas,
                        btn:['Close']
                    });
                }else{
                    layer.msg(e.msg);
                }
            });
        });
    });
</script>